package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

@Entity
public class Position {
    private int postId;//角色
    private Dept dept;//部门
    private String postName;//角色名称
    private Integer postLevel;//角色级别
    private List<Menu> menuList;//权限

    @ManyToMany
    @JoinTable(name = "position_menu",
            joinColumns = {
                    @JoinColumn(name="post_id")
            },
            inverseJoinColumns = {
                    @JoinColumn(name = "Me_id")
            })
    public List<Menu> getMenuList() {
        return menuList;
    }

    public void setMenuList(List<Menu> menuList) {
        this.menuList = menuList;
    }

    @Id
    @Column(name = "post_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getPostId() {
        return postId;
    }

    public void setPostId(int postId) {
        this.postId = postId;
    }

    @ManyToOne
    @JoinColumn(name="dept_id",referencedColumnName = "depts_id")
    public Dept getDept() {
        return dept;
    }

    public void setDept(Dept dept) {
        this.dept = dept;
    }

    @Basic
    @Column(name = "post_name")
    public String getPostName() {
        return postName;
    }

    public void setPostName(String postName) {
        this.postName = postName;
    }

    @Basic
    @Column(name = "post_level")
    public Integer getPostLevel() {
        return postLevel;
    }

    public void setPostLevel(Integer postLevel) {
        this.postLevel = postLevel;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Position position = (Position) o;
        return postId == position.postId &&

                Objects.equals(postName, position.postName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(postId, postName);
    }

    @Override
    public String toString() {
        return "Position{" +
                "postId=" + postId +
                ", postName='" + postName + '\'' +
                '}';
    }
}
